//
//  TestFunc.swift
//  TestSwift
//
//  Created by 小星星吃KFC on 2021/6/1.
//

import Foundation

func TestFunc() {
    
    class Student {
        
    }
    struct SStudent {
        
    }
    print(Student.self)
    print("".self)
    print(Student.Type.self)
    
    /**
     1. AnyObject ：代表任何class类型的对象实例。
     也限制了AnyObject是只适用于Class类型的原因。
     2. Any：可以代表任何类型，甚至包括方法(func)类型。
     
     3. AnyClass：使用不多，更多体现在系统内的使用。
     
     */
    //    var st:AnyObject
    var st:Any
    
    //    st = Student()
    
    st = SStudent()
    
    print("st.self=\(st.self)")
//    print(AnyClass)
    if st.self is Student {
        print("st.self is Student")
    }
    
    /// 判断是不是类型
    if st is Student {
        print("st is Student ")
    }
    if st is SStudent {
        print("st is SStudent ")
    }
    if st is Student.Type {
        print("st is Student.Type")
    }
    if st is SStudent.Type {
        print("st is SStudent.Type")
    }
    /**
     https://www.jianshu.com/p/d7444aacdd83
     Swift中Any，AnyObject，AnyClass的区别
     */
    let swiftInt: Int? = 1
    let swiftString: String = "miao"
    
    var array: [AnyObject] = []
    array.append(swiftInt as AnyObject) //Int,Array是结构体，任意类型用Any,所以类型不符合，要强转类型
    array.append(swiftString as AnyObject)
    print("array=\(array)")
    
    var array1: [AnyObject] = array as [AnyObject]
    array1[0] = 2 as AnyObject
    print("array1=\(array1)")
    print("array=\(array)")
    
    
    func test1(name: String, lowercase: Bool = true)  {
        
        print(name,lowercase)
    }
    
    test1(name: "", lowercase: true)
    test1(name: "")
    
    
}
